package com.isoft.dao.gate;


import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.isoft.entity.ball.Blls;
import com.isoft.entity.gate.Gate;
import org.apache.ibatis.annotations.*;
import org.springframework.web.bind.annotation.DeleteMapping;

import java.io.Serializable;
import java.util.List;

/**
 * 登机口数据层
 */
@Mapper
public interface BoardingGateDao extends BaseMapper<Gate> {
//    通过ID查询
    @Select("SELECT ID,META_ID,GTNO,CODE,ESTR,EEND,BTSC,VALID FROM TEAM04.DFME_GTLS_GTLS_GATE WHERE ID=#{ID}")
    Gate selectBoardingGateByID(Integer ID);
//    查询所有
    @Select("   SELECT ID,META_ID,GTNO,CODE,ESTR,EEND,BTSC,VALID FROM TEAM04.DFME_GTLS_GTLS_GATE" )
    List<Gate> findAllBoardingGate();
//    精确查询
//    @Select(" SELECT ID,META_ID,GTNO,CODE,ESTR,EEND,BTSC FROM TEAM04.DFME_GTLS_GTLS_GATE WHERE META_ID =#{METAID} ")

//    根据航班号META_ID和登机门编号CODE动态和模糊查询
    @Select({
            "<script> ",
            "SELECT ID,META_ID,GTNO,CODE,ESTR,EEND,BTSC,VALID ",
            "FROM TEAM04.DFME_GTLS_GTLS_GATE ",
            "<where> ",
            "<if test='META_ID != null and META_ID != \"\"'> ",
            "AND META_ID LIKE CONCAT('%', #{METAID}, '%') ",
            "</if> ",
            "<if test='CODE != null and CODE != \"\"'> ",
            "AND CODE LIKE CONCAT('%', #{CODE}, '%') ",
            "</if> ",
            "</where> ",
            "</script> "
    })
    List<Gate> findBoardingGateBy(Integer METAID, String CODE);


//    删除
    @Delete("DELETE FROM TEAM04.DFME_GTLS_GTLS_GATE WHERE ID=#{ID}")
    int deleteBoardingGate(Integer ID);

//    修改
    @Update("UPDATE TEAM04.DFME_GTLS_GTLS_GATE SET GTNO=#{GTNO},CODE=#{CODE},ESTR=#{ESTR},EEND=#{EEND},BTSC=#{BTSC},VALID=#{VALID} WHERE ID=#{ID}")
    int updateBoardingGate(Gate gate);
    @Override
    List<Gate> selectList(Wrapper<Gate> queryWrapper);
//    添加
    @Insert("INSERT INTO TEAM04.DFME_GTLS_GTLS_GATE(META_ID,GTNO,CODE,ESTR,EEND,BTSC,VALID) VALUES(#{METAID},#{GTNO},#{CODE},#{ESTR},#{EEND},#{BTSC},#{VALID})")
//    @Insert("INSERT INTO TEAM04.DFME_GTLS_GTLS_GATE(GTNO,CODE,ESTR,EEND,BTSC) VALUES(#{GTNO},#{CODE},#{ESTR},#{EEND},#{BTSC})")
    int insertBoardingGate(Gate gate);
    @Insert("SET IDENTITY_INSERT TEAM04.DFME_GTLS_GTLS_GATE ON")
    void enableIdentityInsert();

    @Insert("SET IDENTITY_INSERT TEAM04.DFME_GTLS_GTLS_GATE OFF")
    void disableIdentityInsert();
}
